import Vue from 'vue'
import VueRouter from 'vue-router'
import Banner from '../views/Banner.vue'
import Layout from '../views/Layout.vue'
import Message from '../views/message/index.vue'
import store from '../store'

Vue.use(VueRouter)

const routes = [{
    path: '/',
    name: 'Banner',
    component: Banner,//导航页轮播图
    
    beforeEnter: (to, from, next) => { //路由独享守卫
        var user=store.state.logMod.username
        if(user){
          next({
            path:'/message'
          })
        }else{
          next()
        }
     }
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/Login.vue'),//登录页面
    
    beforeEnter: (to, from, next) => { //路由独享守卫
      var user=store.state.logMod.username
      if(user){
        next({
          path:'/message'
        })
      }else{
        next()
      }
     }
  },
  {
    path: '/message',
    name: 'Layout',
    component: Layout,
    children: [{
      path: '/message',
      name: 'Message',
      component: Message,
      meta: {
        isLogin: true
      }
    }, {
      path: '/work',
      name: 'Work',
      component: () => import('../views/work/index.vue'),//工作页面
      meta: {
        isLogin: true
      }
    }, {
      path: '/mine',
      name: 'Mine',
      component: () => import('../views/mine/index.vue'),//我的页面
      meta: {
        isLogin: true
      }
    }, {
      path: '/addres',
      name: 'Addres',
      component: () => import('../views/addres/index.vue'),//通讯录页面
      meta: {
        isLogin: true
      }
    }]
  },
  {
      path:'/search',
      name:'Search',
      component:()=>import('../views/message/Search.vue'),//message页面搜索
      meta: {
        isLogin: true
      }
  },{
    path: '/chat/:data',
    name: 'Chat',
    props: true,
    component: () => import('../views/addres/Chat.vue'),
    meta: {
      isLogin: true
    }
  },
  {
    path: '/wechat/:id/:name/:image',
    name: 'Wechat',
    component: () => import('../views/message/Wechat.vue'),//聊天
    meta: {
      isLogin: true
    },
    props: true
  },
    {
    path: '/chatdetails',
    name: 'ChatDetails',
    component: () => import('../views/message/ChatDetails.vue'),//消息-----聊天详情
    meta: {
      isLogin: true
    }
  },
  {
    path: '/chatset/:data',
    name: 'ChatSet',
    component: () => import('../views/addres/ChatSet.vue'),//通讯录---聊天设置
    meta: {
      isLogin: true
    }
  },
  {
    path: '/daily',
      name: 'Daily',
      component: () => import('../views/work/Daily.vue'),//工作-----日常
      meta: {
        isLogin: true
      }
  },{
    path:'/jobtransfer',
    name:'JobTransfer',
    component:()=>import('../views/work/JobTransfer/JobTransfer.vue'),//工作-----岗位调动
    meta: {
      isLogin: true
    }
  },
  {
    path: '/record',
    name: 'Record',
    component: () => import('../views/work/Record.vue'),//交班记录
    meta: {
      isLogin: true
    }
  },{
    path: '/changeinfo',
    name: 'ChangeInfo',
    component: () => import('../views/mine/ChangeInfo.vue'),//我的----更改信息
    meta: {
      isLogin: true
    }
  },
  {
    path: '/equipment',
    name: 'Equipment',
    component: () => import('../views/work/Equipment.vue'),//智能设备
    meta: {
      isLogin: true
    }
  },
  {
    path: '/attendance',
    name: 'Attendance',
    component: () => import('../views/work/Attendance.vue'),//考勤
    meta: {
      isLogin: true
    }
  },{
    path: '/myset',
    name: 'MySet',
    component: () => import('../views/mine/MySet.vue'),//我的-----设置
    meta: {
      isLogin: true
    }
  },
    {
      path:'/changeshifts',
      name:'ChangeShifts',
      component:()=>import('../views/work/JobTransfer/ChangeShifts.vue'),//工作-----岗位调动-----申请换班
      meta: {
        isLogin: true
      },
    },
    {
      path:'/applytransfer',
      name:'ApplyTransfer',
      component:()=>import('../views/work/JobTransfer/ApplyTransfer.vue'),//工作-----岗位调动-----申请调岗
      meta: {
        isLogin: true
      },
    },
    {
      path:'/jobapplication',
      name:'JobApplication',
      component:()=>import('../views/work/JobTransfer/JobApplication.vue'),//工作-----岗位调动-----职位申请
      meta: {
        isLogin: true
      },
    },
    {
      path:'/quit',
      name:'Quit',
      component:()=>import('../views/work/JobTransfer/Quit.vue'),//工作-----岗位调动-----离职
      meta: {
        isLogin: true
      },
    },
    {
      path:'/scheduling',
      name:'Scheduling',
      component:()=>import('../views/work/Scheduling.vue'),//工作-----排班
      meta: {
        isLogin: true
      },
    },
    {
      path:'/carapply',
      name:'CarApply',
      component:()=>import('../views/work/CarApply.vue'),//工作-----用车申请
      meta: {
        isLogin: true
      },
    },
    {
      path:'/goods',
      name:'Goods',
      component:()=>import('../views/work/Goods.vue'),//工作-----物品领用
      meta: {
        isLogin: true
      },
    },
    {
      path:'/buyapply',
      name:'BuyApply',
      component:()=>import('../views/work/BuyApply.vue'),//工作-----物品领用----采购申请
      meta: {
        isLogin: true
      },
    },
    {
      path:'/approval',
      name:'Approval',
      component:()=>import('../views/work/Approval.vue'),//工作-----审批
      meta: {
        isLogin: true
      },
    },
    {
      path:'/leave',
      name: 'Leave',
      component: () => import('../views/work/Leave.vue'),
      meta: {
        isLogin: true
      }
    },
    {
      path:'/calendar',
      name: 'Calendar',
      component: () => import('../views/work/Calendar.vue'),
      meta: {
        isLogin: true
      }
    } ,
    {
      path:'/location',
      name: 'Location',
      component: () => import('../views/work/Location.vue'),
      meta: {
        isLogin: true
      }
    } ,{
      path:'/safety',
      name:'Safety',
      component:()=>import('../views/mine/Safety.vue'),//我的-----账号与安全
      meta: {
        isLogin: true
      },
    },
    {
      path:'/newinfo',
      name:'NewInfo',
      component:()=>import('../views/mine/NewInfo.vue'),//我的-----新消息通知
      meta: {
        isLogin: true
      },
    },
    {
      path:'/privacy',
      name:'Privacy',
      component:()=>import('../views/mine/Privacy.vue'),//我的-----隐私
      meta: {
        isLogin: true
      },
    },
    {
      path:'/universal',
      name:'Universal',
      component:()=>import('../views/mine/Universal.vue'),//我的-----通用
      meta: {
        isLogin: true
      },
    },
    {
      path:'/langchoose',
      name:'LangChoose',
      component:()=>import('../views/mine/LangChoose.vue'),//我的-----语言选择
      meta: {
        isLogin: true
      },
    },
    {
      path:'/textsize',
      name:'TextSize',
      component:()=>import('../views/mine/TextSize.vue'),//我的-----文字大小
      meta: {
        isLogin: true
      },
    },
    {
      path:'/initiategroupchat',
      name:'InitiateGroupChat',
      component:()=>import('../views/addres/InitiateGroupChat.vue'),//通讯录------发起群聊
      meta: {
        isLogin: true
      },
    },
    // {
    //   path:'/daily',
    //   name: 'Daily',
    //   component: () => import('../views/work/Daily.vue'),
    //   meta: {
    //     isLogin: true
    //   }
    // } 
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router